<template>
<div>
    标题：{{title}}<br>
    标题1：{{title1}}<br>
    姓名：{{name}} <br>
    <button @click="handleTitle">修改标题</button>
    <button @click="handleName">修改姓名</button>
</div>
</template>
<script setup lang="ts">
import {ref,inject} from 'vue'
defineOptions({
    name:'Child'
})
defineProps({
    title:{
        type:String
    },
    name:{
        type:String
    }
})
const title1 = inject('title1')
const emit = defineEmits(['update:name','changeTitle'])
const handleTitle = ()=>{
    emit('changeTitle','标题修改成功')
}
const handleName = ()=>{
    emit('update:name','张三')
}
defineExpose({
    handleName
})
</script>